<template>
  <v-btn text icon :color="status ? 'pink' : 'blue'" @click.stop="toggle">
    <v-icon>mdi-heart</v-icon>
  </v-btn>
</template>

<script>
export default {
  props: {
    type: {
      type: String,
      requierd: true,
    },
    object: {
      type: String,
      requierd: true,
    },
  },
  data() {
    return {
      status: false,
    }
  },
  methods: {
    async getStatus() {
      //$axios.get 不需要返回data 直接是返回res.data的数据
      const res = await this.$axios.$get('actions/status', {
        params: {
          type: this.type,
          object: this.object,
          name: 'like',
        },
      })
      this.status = res.status
    },
    async toggle() {
      const ret = await this.$axios.$post('actions/toggle', {
        type: this.type,
        object: this.object,
        name: 'like',
      })
      this.status = ret.status
    },
  },
  mounted() {
    this.getStatus()
  },
}
</script>


<style scoped>
</style>
